package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * 这个主要练习的是修改update
 */
public class JdbcDemo03 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection =DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/tedu?" +
                        "serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true",
                "root",
                "root"
        );
        Statement statement = connection.createStatement();
       //String sql = "update userinfo set name='琪琪' where id=3";
       // String sql = "update userinfo set name='四儿' ,age=10 where name='李四'";
        String sql = "update userinfo set age=18 ";
        int num = statement.executeUpdate(sql);
        if (num > 0) {
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
        }
        connection.close();
    }
}
